package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMM9805{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public SelectResultRset SELECT_FLATC01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT");
		sql.append(" NVL( TRPT_ENGL_NM ,' ') AS TRPT_ENGL_NM ,");
		sql.append(" NVL( TRPT_ENGL_AB ,' ') AS TRPT_ENGL_AB ,");
		sql.append(" NVL( RGN_TYP ,' ') AS RGN_TYP ,");
		sql.append(" NVL( CNTY_CD ,' ') AS CNTY_CD ,");
		sql.append(" NVL( ADR_CD ,' ') AS ADR_CD ,");
		sql.append(" NVL( PST_NO ,' ') AS PST_NO ,");
		sql.append(" NVL( TRPT_ENGL_ADR ,' ') AS TRPT_ENGL_ADR ,");
		sql.append(" NVL( TEL_NO ,' ') AS TEL_NO ,");
		sql.append(" NVL( FAX_NO ,' ') AS FAX_NO ,");
		sql.append(" NVL( TLX_NO ,' ') AS TLX_NO ,");
		sql.append(" NVL( CO_CD ,' ') AS CO_CD ,");
		sql.append(" NVL( P_G_CD ,' ') AS P_G_CD");
		sql.append(" FROM");
		sql.append(" FLATC");
		sql.append(" WHERE");
		sql.append(" FLT_CD "+((getString("VDR_CD").equals(""))?" is null ":"=")+getString("VDR_CD")+"");
		sql.append(" AND");
		sql.append(" APL_BDT <"+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_M0101(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT");
		sql.append(" NVL(VDR_CD,'') AS VDR_CD,");
		sql.append(" NVL(APL_BDT,'') AS APL_BDT,");
		sql.append(" NVL(APL_EDT,'') AS APL_EDT,");
		sql.append(" NVL(GNR_ADM_NO,'') AS GNR_ADM_NO,");
		sql.append(" NVL(TMP_AC_TYP,'') AS TMP_AC_TYP,");
		sql.append(" NVL(CTRL_DVSN_CD,'') AS CTRL_DVSN_CD,");
		sql.append(" NVL(TRPT_CLSS_D_TYP,'') AS TRPT_CLSS_D_TYP,");
		sql.append(" NVL(CTY_CD,'') AS CTY_CD,");
		sql.append(" NVL(CN_PST_CD,'') AS CN_PST_CD,");
		sql.append(" NVL(TRPT_ADR_CN,'') AS TRPT_ADR_CN,");
		sql.append(" NVL(TRPT_NM_CN,'') AS TRPT_NM_CN,");
		sql.append(" NVL(TRPT_AB_CN,'') AS TRPT_AB_CN,");
		sql.append(" NVL(TEL_NO,'') AS TEL_NO,");
		sql.append(" NVL(FAX_NO,'') AS FAX_NO,");
		sql.append(" NVL(CUS_CLSS_CD,'') AS CUS_CLSS_CD,");
		sql.append(" NVL(CUS_CLSS_DTL_CD,'') AS CUS_CLSS_DTL_CD,");
		sql.append(" NVL(SLS_CHRG_CD,'') AS SLS_CHRG_CD,");
		sql.append(" NVL(SLS_CHNL_CD,'') AS SLS_CHNL_CD,");
		sql.append(" NVL(SLS_SLS_DEPT,'') AS SLS_SLS_DEPT,");
		sql.append(" NVL(BRNC_CD,'') AS BRNC_CD,");
		sql.append(" NVL(SUB_BRNC_CD,'') AS SUB_BRNC_CD,");
		sql.append(" NVL(SUB_SECT_CD,'') AS SUB_SECT_CD,");
		sql.append(" NVL(SLS_CHNL_RGN_CD,'') AS RGN_CD,");
		sql.append(" NVL(STATE_CD,'') AS STATE_CD,");
		sql.append(" NVL(AREA_CD,'') AS AREA_CD,");
		sql.append(" NVL(GRP_CD1,'') AS GRP_CD1,");
		sql.append(" NVL(GRP_CD2,'') AS GRP_CD2,");
		sql.append(" NVL(GRP_CD3,'') AS GRP_CD3,");
		sql.append(" NVL(GRP_CD4,'') AS GRP_CD4,");
		sql.append(" NVL(SLS_DEST,'') AS SLS_DEST,");
		sql.append(" NVL(CORP_CD,'') AS CORP_CD,");
		sql.append(" NVL(CDR_CD,'') AS CDR_CD,");
		sql.append(" NVL(OLD_CUS_CD1,'') AS OLD_CUS_CD1,");
		sql.append(" NVL(OLD_CUS_CD2,'') AS OLD_CUS_CD2,");
		sql.append(" NVL(OLD_CUS_CD3,'') AS OLD_CUS_CD3,");
		sql.append(" NVL(RMK,'') AS RMK,");
		sql.append(" NVL(PMIT_CLNT_CD,'') AS PMIT_CLNT_CD,");
		sql.append(" NVL(DFLT_SHP_DSTN_CD,'') AS DFLT_SHP_DSTN_CD,");
		sql.append(" NVL(DSP_ITM_CLNT_TYP,'') AS DSP_ITM_CLNT_TYP,");
		sql.append(" NVL(CNSMT_ITM_CLNT_TYP,'') AS CNSMT_ITM_CLNT_TYP,");
		sql.append(" NVL(FRNT_WHRS_CD,'') AS FRNT_WHRS_CD,");
		sql.append(" NVL(BIL_DSTN_CD,'') AS BIL_DSTN_CD,");
		sql.append(" NVL(CUS_PYMT_PRID,'') AS CUS_PYMT_PRID,");
		sql.append(" NVL(CUS_BNK_CD,'') AS CUS_BNK_CD,");
		sql.append(" NVL(CUS_BNK_ACC,'') AS CUS_BNK_ACC,");
		sql.append(" NVL(CUS_CRDT_LMT_AMT,'') AS CUS_CRDT_LMT_AMT,");
		sql.append(" NVL(CUS_ADD_PRIZ_TAX_CD,'') AS CUS_ADD_PRIZ_TAX_CD,");
		sql.append(" NVL(CUS_ADD_PRIZ_CAL_TYP,'') AS CUS_ADD_PRIZ_CAL_TYP,");
		sql.append(" NVL(CUS_ADD_PRIZ_RGS_NO,'') AS CUS_ADD_PRIZ_RGS_NO,");
		sql.append(" NVL(CUS_MLT_CRCY,'') AS CUS_MLT_CRCY,");
		sql.append(" NVL(CUS_CRCY_CD,'') AS CUS_CRCY_CD,");
		sql.append(" NVL(CUS_AR_AC,'') AS CUS_AR_AC,");
		sql.append(" NVL(CUS_PRFT_AC,'') AS CUS_PRFT_AC,");
		sql.append(" NVL(CUS_TAX_AC,'') AS CUS_TAX_AC,");
		sql.append(" NVL(SUP_DEBT_AC,'') AS SUP_DEBT_AC,");
		sql.append(" NVL(SUP_PRPY_AC,'') AS SUP_PRPY_AC,");
		sql.append(" NVL(SUP_PRPYFT_AC,'') AS SUP_PRPYFT_AC,");
		sql.append(" NVL(SUP_PYMT_PRID,'') AS SUP_PYMT_PRID,");
		sql.append(" NVL(OVS_SUP_TYP,'') AS OVS_SUP_TYP,");
		sql.append(" NVL(MAIN_STR_TYP,'') AS MAIN_STR_TYP,");
		sql.append(" NVL(CONS_AC_TYP,'') AS CONS_AC_TYP,");
		sql.append(" NVL(DFLT_RCV_DSTN_CD,'')AS DFLT_RCV_DSTN_CD,");
		sql.append(" NVL(SITE_NM,'') AS SITE_NM,");
		sql.append(" NVL(SUP_ADD_PRIZ_TAX_CD,'') AS SUP_ADD_PRIZ_TAX_CD,");
		sql.append(" NVL(CUS_PRC_TAB_CD,'') AS CUS_PRC_TAB_CD,");
		sql.append(" TO_CHAR(NVL(RGS_DTTM,''),'YYYYMMDD HH24:MI:SS') AS RGS_DTTM,");
		sql.append(" NVL(RGS_CHRG_CD,'') AS RGS_CHRG_CD,");
		sql.append(" NVL(RGS_PGID,'') AS RGS_PGID,");
		sql.append(" TO_CHAR(NVL(UPD_DTTM,''),'YYYYMMDD HH24:MI:SS') AS UPD_DTTM,");
		sql.append(" NVL(UPD_CHRG_CD,'') AS UPD_CHRG_CD,");
		sql.append(" NVL(UPD_PGID,'') AS UPD_PGID,");
		sql.append(" NVL(FM_TYP,'') AS FM_TYP");
		sql.append(" FROM");
		sql.append(" M01");
		sql.append(" WHERE");
		sql.append(" VDR_CD "+((getString("VDR_CD").equals(""))?" is null ":"=")+getString("VDR_CD")+"");
		sql.append(" AND");
		sql.append(" APL_BDT "+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append(" ORDER BY VDR_CD,APL_BDT");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_M0102(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT");
		sql.append(" TRPT_NM_CN");
		sql.append(" FROM");
		sql.append(" M01");
		sql.append(" WHERE");
		sql.append(" VDR_CD "+((getString("VDR_CD").equals(""))?" is null ":"=")+getString("VDR_CD")+"");
		sql.append(" AND");
		sql.append(" APL_BDT <"+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append(" AND");
		sql.append(" APL_EDT >"+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append(" AND");
		sql.append(" FM_TYP <> "+getString("FM_TYP_6")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public SelectResultRset SELECT_M1503(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT");
		sql.append(" WHRS_NM_CN");
		sql.append(" FROM");
		sql.append(" M15");
		sql.append(" WHERE");
		sql.append(" CTRL_DVSN_CD "+((getString("CTRL_DVSN_CD").equals(""))?" is null ":"=")+getString("CTRL_DVSN_CD")+"");
		sql.append(" AND");
		sql.append(" WHRS_CD "+((getString("WHRS_CD").equals(""))?" is null ":"=")+getString("WHRS_CD")+"");
		sql.append(" AND");
		sql.append(" APL_BDT <"+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append(" AND");
		sql.append(" APL_EDT >"+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		sql.append(" AND");
		sql.append(" FM_TYP <> "+getString("FM_TYP_X")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}


	public void setVDR_CD(String value){
		if(value==null) {
			paramsString.remove("VDR_CD");
			return;
		}
		paramsString.put("VDR_CD",value);
	}


	public void setAPL_BDT(String value){
		if(value==null) {
			paramsString.remove("APL_BDT");
			return;
		}
		paramsString.put("APL_BDT",value);
	}


	public void setFM_TYP_6(String value){
		if(value==null) {
			paramsString.remove("FM_TYP_6");
			return;
		}
		paramsString.put("FM_TYP_6",value);
	}


	public void setCTRL_DVSN_CD(String value){
		if(value==null) {
			paramsString.remove("CTRL_DVSN_CD");
			return;
		}
		paramsString.put("CTRL_DVSN_CD",value);
	}


	public void setWHRS_CD(String value){
		if(value==null) {
			paramsString.remove("WHRS_CD");
			return;
		}
		paramsString.put("WHRS_CD",value);
	}


	public void setFM_TYP_X(String value){
		if(value==null) {
			paramsString.remove("FM_TYP_X");
			return;
		}
		paramsString.put("FM_TYP_X",value);
	}


}
